package net.lshimokawa.corespring.nbdemo.controller;

import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.lshimokawa.corespring.nbdemo.model.Cliente;
import net.lshimokawa.corespring.nbdemo.service.ClienteService;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

/**
 *
 * @author Lennon Shimokawa
 */
public class ClienteController implements Controller {

    /**
     * ClienteService es una interface, se programa contra la interface
     */
    private ClienteService clienteService;

    public ModelAndView handleRequest(HttpServletRequest req, HttpServletResponse res) throws Exception {
        List<Cliente> clientes = clienteService.getClientes();
        return new ModelAndView("clientes", "clientes", clientes);
    }

    public void setClienteService(ClienteService clienteService) {
        this.clienteService = clienteService;
    }
}
